/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package CustomComponents;

import AreaDeDesenho.PainelDeDesenho;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 *
 * @author Lilli
 */
public class JCustomColorChooser extends JPanel implements MouseListener, ChangeListener {

    private PainelDeDesenho painel;
    private JColorChooser chooser;

    public JCustomColorChooser(PainelDeDesenho painel) {
        this.painel = painel;
        chooser = new JColorChooser();
        this.add(chooser);
        this.addMouseListener(this);
        chooser.addMouseListener(this);

        for (AbstractColorChooserPanel pan : chooser.getChooserPanels()) {
            pan.getColorSelectionModel().addChangeListener(this);
            pan.addMouseListener(this);
        }

    }

    @Override
    public void mouseClicked(MouseEvent e) {
        PainelDeDesenho.setCorDoPincel(chooser.getColor());
    }

    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }

    @Override
    public void stateChanged(ChangeEvent e) {
        PainelDeDesenho.setCorDoPincel(chooser.getColor());
    }
}
